package com.zed.api.games;

import com.zed.api.domain.repository.QueryRepository;

/**
 * 游戏构建器仓储,让其他模块实现{@link GameBuilder},并注册进来该仓储
 * 1.使用场景为当用户开始游戏时候,从游戏构建器new一个{@link Game}
 *
 * @author Zed
 */
public interface GameBuilderRepository extends QueryRepository<String, GameBuilder<?, ? extends Action>> {

    /**
     * 注册游戏进入游戏仓储
     */
    void registerGameBuilder(GameBuilder<?, ? extends Action> builder) throws GameAlreadyExistException;

    /**
     * 根据游戏构建查询并 {@code clazz}转换
     *
     * @param builderId {@link String},游戏构建Id
     * @param clazz     {@link Class<?>},转换类型
     * @return {@link G},可能为null
     */
    <G extends GameBuilder<?, ? extends Action>> G findById(String builderId, Class<G> clazz);
}